<?php

function micro_time()
{
   list($usec, $sec) = explode(" ", microtime());
   return ($usec * 1000000 + $sec * 1000000);
}

$ip   = "14.18.204.246:3306";
$user = 'root';
$pass = '8zDNBNooQxbn';
$db   = "test";

$conn = new mysqli($ip, $user, $pass, $db);
if (mysqli_connect_errno($conn)) {
    echo "连接 MySQL 失败: ".mysqli_connect_error()."\n";
}
$starttime = micro_time();
$res = mysqli_query($conn, "select * from user limit 1");
$endtime = micro_time();
var_dump("时间差:" . ($endtime - $starttime));
print_r($res);

// $name = 'asdf';
// $sql = "select * from user where `name` = ? limit 1";
// $stmt = $conn->prepare($sql);
// $stmt->bind_param('s', $name);
// $stmt->execute();
// if ($conn->affected_rows) {
//     $result = $stmt->get_result();
//     while ($row = $result->fetch_assoc()) {
//         var_dump($row);
//     }
// }

mysqli_close($conn);